﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefProductionPlanning" :model="stateProductionPlanning.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Wo_FormItem" prop="LinkedVM.Wo" :label="$t('message.autotrans._Model_ProductionPlanning_Wo')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.Wo" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Sort_FormItem" prop="LinkedVM.Sort" :label="$t('message.autotrans._Model_ProductionPlanning_Sort')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionPlanning_Sort')}), trigger: 'blur' }]" >
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.Sort" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineId_FormItem" prop="LinkedVM.LineId" :label="$t('message.autotrans._Model_ProductionPlanning_LineId')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.LineId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineCode_FormItem" prop="LinkedVM.LineCode" :label="$t('message.autotrans._Model_ProductionPlanning_LineCode')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.LineCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ShiftId_FormItem" prop="LinkedVM.ShiftId" :label="$t('message.autotrans._Model_ProductionPlanning_ShiftId')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.ShiftId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ShiftCode_FormItem" prop="LinkedVM.ShiftCode" :label="$t('message.autotrans._Model_ProductionPlanning_ShiftCode')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.ShiftCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductId_FormItem" prop="LinkedVM.ProductId" :label="$t('message.autotrans._Model_ProductionPlanning_ProductId')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.ProductId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductCode_FormItem" prop="LinkedVM.ProductCode" :label="$t('message.autotrans._Model_ProductionPlanning_ProductCode')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.ProductCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ProductName_FormItem" prop="LinkedVM.ProductName" :label="$t('message.autotrans._Model_ProductionPlanning_ProductName')">
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.ProductName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_PlanStartTime_FormItem" prop="LinkedVM.PlanStartTime" :label="$t('message.autotrans._Model_ProductionPlanning_PlanStartTime')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionPlanning_PlanStartTime')}), trigger: 'blur' }]" >
          <el-date-picker v-model="stateProductionPlanning.vmModel.LinkedVM.PlanStartTime" type='date' clearable></el-date-picker>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_PlanEndTime_FormItem" prop="LinkedVM.PlanEndTime" :label="$t('message.autotrans._Model_ProductionPlanning_PlanEndTime')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionPlanning_PlanEndTime')}), trigger: 'blur' }]" >
          <el-date-picker v-model="stateProductionPlanning.vmModel.LinkedVM.PlanEndTime" type='date' clearable></el-date-picker>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_PlanQty_FormItem" prop="LinkedVM.PlanQty" :label="$t('message.autotrans._Model_ProductionPlanning_PlanQty')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionPlanning_PlanQty')}), trigger: 'blur' }]" >
          <el-input v-model="stateProductionPlanning.vmModel.LinkedVM.PlanQty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_PlanStatus_FormItem" prop="LinkedVM.PlanStatus" :label="$t('message.autotrans._Model_ProductionPlanning_PlanStatus')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProductionPlanning_PlanStatus')}), trigger: 'blur' }]" >
          <el-select v-model="stateProductionPlanning.vmModel.LinkedVM.PlanStatus" clearable>
             <el-option key="Created" value="Created" :label="$t('message.autotrans._Enum_WoStatusEnum_Created')"></el-option>
             <el-option key="Scheduled" value="Scheduled" :label="$t('message.autotrans._Enum_WoStatusEnum_Scheduled')"></el-option>
             <el-option key="Issued" value="Issued" :label="$t('message.autotrans._Enum_WoStatusEnum_Issued')"></el-option>
             <el-option key="Executing" value="Executing" :label="$t('message.autotrans._Enum_WoStatusEnum_Executing')"></el-option>
             <el-option key="Completed" value="Completed" :label="$t('message.autotrans._Enum_WoStatusEnum_Completed')"></el-option>
             <el-option key="Paused" value="Paused" :label="$t('message.autotrans._Enum_WoStatusEnum_Paused')"></el-option>
             <el-option key="Freezed" value="Freezed" :label="$t('message.autotrans._Enum_WoStatusEnum_Freezed')"></el-option>
             <el-option key="Canceled" value="Canceled" :label="$t('message.autotrans._Enum_WoStatusEnum_Canceled')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitProductionPlanning"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseProductionPlanning"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PagePlanningManagementProductionPlanningBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { productionplanningApi } from '/@/api/planningmanagement/productionplanning';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProductionPlanning = ref();
const stateProductionPlanning = reactive({
    vmModel: {
	  LinkedVM:{
        Wo: '',
        LineCode: '',
        ShiftCode: '',
        ProductCode: '',
        ProductName: '',
        PlanStartTime: undefined,
        PlanEndTime: undefined,
        PlanStatus: undefined,
      },
      Ids:[],
      
	},
    
});

// 取消
const onCloseProductionPlanning = () => {
    closeDialog();
};

// 提交
const onSubmitProductionPlanning = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefProductionPlanning.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            productionplanningApi().batchedit(stateProductionPlanning.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateProductionPlanning.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProductionPlanning.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

